home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Bank smakow / BankSmakow.air / BankSmakow.swf / scripts / mx / effects / effectClasses / ParallelInstance.as < prev    next >
Text File  |  2009-12-16  |  8KB  |  290 lines

  1. package mx.effects.effectClasses
  2. {
  3.    import flash.events.TimerEvent;
  4.    import flash.utils.Timer;
  5.    import mx.core.UIComponent;
  6.    import mx.core.mx_internal;
  7.    import mx.effects.EffectInstance;
  8.    import mx.effects.IEffectInstance;
  9.    
  10.    use namespace mx_internal;
  11.    
  12.    public class ParallelInstance extends CompositeEffectInstance
  13.    {
  14.       
  15.       mx_internal static const VERSION:String = "3.5.0.12683";
  16.        
  17.       
  18.       private var timer:Timer;
  19.       
  20.       private var isReversed:Boolean = false;
  21.       
  22.       private var replayEffectQueue:Array;
  23.       
  24.       private var doneEffectQueue:Array;
  25.       
  26.       public function ParallelInstance(param1:Object)
  27.       {
  28.          super(param1);
  29.       }
  30.       
  31.       override public function stop() : void
  32.       {
  33.          var _loc1_:Array = null;
  34.          var _loc2_:int = 0;
  35.          var _loc3_:int = 0;
  36.          stopTimer();
  37.          if(mx_internal::activeEffectQueue)
  38.          {
  39.             _loc1_ = mx_internal::activeEffectQueue.concat();
  40.             activeEffectQueue = null;
  41.             _loc2_ = _loc1_.length;
  42.             _loc3_ = 0;
  43.             while(_loc3_ < _loc2_)
  44.             {
  45.                if(_loc1_[_loc3_])
  46.                {
  47.                   _loc1_[_loc3_].stop();
  48.                }
  49.                _loc3_++;
  50.             }
  51.          }
  52.          super.stop();
  53.       }
  54.       
  55.       private function startTimer() : void
  56.       {
  57.          if(!timer)
  58.          {
  59.             timer = new Timer(10);
  60.             timer.addEventListener(TimerEvent.TIMER,timerHandler);
  61.          }
  62.          timer.start();
  63.       }
  64.       
  65.       override mx_internal function get durationWithoutRepeat() : Number
  66.       {
  67.          var _loc4_:Array = null;
  68.          var _loc1_:Number = 0;
  69.          var _loc2_:int = mx_internal::childSets.length;
  70.          var _loc3_:int = 0;
  71.          while(_loc3_ < _loc2_)
  72.          {
  73.             _loc4_ = mx_internal::childSets[_loc3_];
  74.             _loc1_ = Math.max(_loc4_[0].actualDuration,_loc1_);
  75.             _loc3_++;
  76.          }
  77.          return _loc1_;
  78.       }
  79.       
  80.       private function timerHandler(param1:TimerEvent) : void
  81.       {
  82.          var _loc5_:EffectInstance = null;
  83.          var _loc2_:Number = mx_internal::durationWithoutRepeat - playheadTime;
  84.          var _loc3_:int = replayEffectQueue.length;
  85.          if(_loc3_ == 0)
  86.          {
  87.             stopTimer();
  88.             return;
  89.          }
  90.          var _loc4_:int = _loc3_ - 1;
  91.          while(_loc4_ >= 0)
  92.          {
  93.             _loc5_ = replayEffectQueue[_loc4_];
  94.             if(_loc2_ <= _loc5_.actualDuration)
  95.             {
  96.                mx_internal::activeEffectQueue.push(_loc5_);
  97.                replayEffectQueue.splice(_loc4_,1);
  98.                _loc5_.playReversed = mx_internal::playReversed;
  99.                _loc5_.startEffect();
  100.             }
  101.             _loc4_--;
  102.          }
  103.       }
  104.       
  105.       private function stopTimer() : void
  106.       {
  107.          if(timer)
  108.          {
  109.             timer.reset();
  110.          }
  111.       }
  112.       
  113.       override public function addChildSet(param1:Array) : void
  114.       {
  115.          var _loc2_:CompositeEffectInstance = null;
  116.          super.addChildSet(param1);
  117.          if(param1.length > 0)
  118.          {
  119.             _loc2_ = param1[0] as CompositeEffectInstance;
  120.             if(param1[0] is RotateInstance || _loc2_ != null && _loc2_.hasRotateInstance())
  121.             {
  122.                mx_internal::childSets.pop();
  123.                mx_internal::childSets.unshift(param1);
  124.             }
  125.          }
  126.       }
  127.       
  128.       override public function reverse() : void
  129.       {
  130.          var _loc1_:int = 0;
  131.          var _loc2_:int = 0;
  132.          super.reverse();
  133.          if(isReversed)
  134.          {
  135.             _loc1_ = mx_internal::activeEffectQueue.length;
  136.             _loc2_ = 0;
  137.             while(_loc2_ < _loc1_)
  138.             {
  139.                mx_internal::activeEffectQueue[_loc2_].reverse();
  140.                _loc2_++;
  141.             }
  142.             stopTimer();
  143.          }
  144.          else
  145.          {
  146.             replayEffectQueue = doneEffectQueue.splice(0);
  147.             _loc1_ = mx_internal::activeEffectQueue.length;
  148.             _loc2_ = 0;
  149.             while(_loc2_ < _loc1_)
  150.             {
  151.                mx_internal::activeEffectQueue[_loc2_].reverse();
  152.                _loc2_++;
  153.             }
  154.             startTimer();
  155.          }
  156.          isReversed = !isReversed;
  157.       }
  158.       
  159.       override public function end() : void
  160.       {
  161.          var _loc1_:Array = null;
  162.          var _loc2_:int = 0;
  163.          var _loc3_:int = 0;
  164.          endEffectCalled = true;
  165.          stopTimer();
  166.          if(mx_internal::activeEffectQueue)
  167.          {
  168.             _loc1_ = mx_internal::activeEffectQueue.concat();
  169.             activeEffectQueue = null;
  170.             _loc2_ = _loc1_.length;
  171.             _loc3_ = 0;
  172.             while(_loc3_ < _loc2_)
  173.             {
  174.                if(_loc1_[_loc3_])
  175.                {
  176.                   _loc1_[_loc3_].end();
  177.                }
  178.                _loc3_++;
  179.             }
  180.          }
  181.          super.end();
  182.       }
  183.       
  184.       override protected function onEffectEnd(param1:IEffectInstance) : void
  185.       {
  186.          if(Object(param1).suspendBackgroundProcessing)
  187.          {
  188.             UIComponent.resumeBackgroundProcessing();
  189.          }
  190.          if(mx_internal::endEffectCalled || mx_internal::activeEffectQueue == null)
  191.          {
  192.             return;
  193.          }
  194.          var _loc2_:int = mx_internal::activeEffectQueue.length;
  195.          var _loc3_:int = 0;
  196.          while(_loc3_ < _loc2_)
  197.          {
  198.             if(param1 == mx_internal::activeEffectQueue[_loc3_])
  199.             {
  200.                doneEffectQueue.push(param1);
  201.                mx_internal::activeEffectQueue.splice(_loc3_,1);
  202.                break;
  203.             }
  204.             _loc3_++;
  205.          }
  206.          if(_loc2_ == 1)
  207.          {
  208.             finishRepeat();
  209.          }
  210.       }
  211.       
  212.       override public function resume() : void
  213.       {
  214.          super.resume();
  215.          var _loc1_:int = mx_internal::activeEffectQueue.length;
  216.          var _loc2_:int = 0;
  217.          while(_loc2_ < _loc1_)
  218.          {
  219.             mx_internal::activeEffectQueue[_loc2_].resume();
  220.             _loc2_++;
  221.          }
  222.       }
  223.       
  224.       override public function play() : void
  225.       {
  226.          var _loc2_:int = 0;
  227.          var _loc3_:int = 0;
  228.          var _loc4_:Array = null;
  229.          var _loc5_:int = 0;
  230.          var _loc6_:int = 0;
  231.          var _loc7_:EffectInstance = null;
  232.          var _loc8_:Array = null;
  233.          doneEffectQueue = [];
  234.          activeEffectQueue = [];
  235.          replayEffectQueue = [];
  236.          var _loc1_:Boolean = false;
  237.          super.play();
  238.          _loc2_ = mx_internal::childSets.length;
  239.          _loc3_ = 0;
  240.          while(_loc3_ < _loc2_)
  241.          {
  242.             _loc5_ = (_loc4_ = mx_internal::childSets[_loc3_]).length;
  243.             _loc6_ = 0;
  244.             while(_loc6_ < _loc5_ && mx_internal::activeEffectQueue != null)
  245.             {
  246.                _loc7_ = _loc4_[_loc6_];
  247.                if(mx_internal::playReversed && _loc7_.actualDuration < mx_internal::durationWithoutRepeat)
  248.                {
  249.                   replayEffectQueue.push(_loc7_);
  250.                   startTimer();
  251.                }
  252.                else
  253.                {
  254.                   _loc7_.playReversed = mx_internal::playReversed;
  255.                   mx_internal::activeEffectQueue.push(_loc7_);
  256.                }
  257.                if(_loc7_.suspendBackgroundProcessing)
  258.                {
  259.                   UIComponent.suspendBackgroundProcessing();
  260.                }
  261.                _loc6_++;
  262.             }
  263.             _loc3_++;
  264.          }
  265.          if(mx_internal::activeEffectQueue.length > 0)
  266.          {
  267.             _loc8_ = mx_internal::activeEffectQueue.slice(0);
  268.             _loc3_ = 0;
  269.             while(_loc3_ < _loc8_.length)
  270.             {
  271.                _loc8_[_loc3_].startEffect();
  272.                _loc3_++;
  273.             }
  274.          }
  275.       }
  276.       
  277.       override public function pause() : void
  278.       {
  279.          super.pause();
  280.          var _loc1_:int = mx_internal::activeEffectQueue.length;
  281.          var _loc2_:int = 0;
  282.          while(_loc2_ < _loc1_)
  283.          {
  284.             mx_internal::activeEffectQueue[_loc2_].pause();
  285.             _loc2_++;
  286.          }
  287.       }
  288.    }
  289. }
  290.